<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>testD3-3-drawingDivBar</title>
<script type="text/javascript" src="d3.js"></script>
<style type="text/css">
div.bar {
    display: inline-block;
    width: 20px;
    margin-right: 2px;
    background-color: teal;
}
</style>
</head>
<body>
<p>设置类和属性</p>
<script type="text/javascript">

    var dataset = [ 5, 10, 15, 20, 25 ];

    d3.select("body").selectAll("div")
        .data(dataset)
        .enter()
        .append("div")
        .attr("class", "bar")
        .style("height", function(d) {
            return (d * 5) + "px";
        });

</script>
</body>
</html>